package cn.git.bbs.core.controller;



import cn.git.bbs.core.bean.product.Brand;
import cn.git.bbs.core.service.brand.BrandService;
import cn.itcast.common.page.Pagination;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;




@Controller
public class BrandController {

    @Autowired
    BrandService brandService;
    @RequestMapping("/brand/list.do")
    public String list(String name,boolean isDisplay,Model model,Integer pageNo){

        Pagination pagination = brandService.selectPagination(name,isDisplay,pageNo);

        model.addAttribute("pagination",pagination);
        model.addAttribute("name",name);

        return "brand/list";
    }
    @RequestMapping("/brand/edit.do")
    public String edit(Model model,Long id){
        Brand brand = brandService.selectBrandById(id);
        model.addAttribute("brand",brand);
        return "brand/edit";
    }
    @RequestMapping("/brand/toEdit")
    public String toEdit(Brand brand){
        brandService.updateById(brand);
        return "redirect:list.do";
    }


}
